package com.javafactroy.kunlong.bip.icp.message.test.netty.codec;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import io.netty.util.ReferenceCountUtil;
import com.javafactroy.kunlong.bip.icp.message.base.iface.IMessage;

public class TMsgMsg2ByteEncoder extends MessageToByteEncoder<IMessage> {
    @Override
    protected void encode(ChannelHandlerContext channelHandlerContext, IMessage msg, ByteBuf byteBuf) throws Exception {
        ByteBuf bb = msg.encode2ByteBuf();
        byteBuf.writeBytes(bb);
        //bb.release();
        ReferenceCountUtil.release(bb);
    }
}
